package lv.yasa;

import lv.yasa.helper.FSHelper;
import lv.yasa.manager.YasaManager;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;
 
public class ISTView extends LinearLayout
{
	public enum ISTType {
		Item, Category
	}
	
	ISTType type;
	ISTCallback callback;
	Object clickObject;
	String text;
	TextView textViewText;
	ImageView imageViewImage;
	public ISTView(Context context)
	{
		super(context);
		 
		LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		layoutInflater.inflate(R.layout.ist,this);

		textViewText = (TextView)findViewById(R.id.textViewText);
		imageViewImage = (ImageView)findViewById(R.id.imageViewImage);		
		
		imageViewImage.setMaxWidth(80);
		imageViewImage.setMaxHeight(50);  
		
		imageViewImage.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Perform action on click
            	imageOnClick();
            }
        });  
	}

	public void imageOnClick()
	{
		setImage("1.jpg");
		if (callback != null)
		{
			callback.onISTClick(clickObject);
		}
	}
	
	public void setCallback(ISTCallback callback)
	{
		this.callback = callback;
	}
	
	public void setClickObject(Object object)
	{
		this.clickObject = object;
	}
	
	public void setText(String text)
	{
		this.text = text;
		textViewText.setText(text);
	}

	public void setImage(String imagePath)
	{
		Bitmap bmp = FSHelper.getFileBitmap(imagePath);
		if (bmp != null)
		{
			imageViewImage.setImageBitmap(bmp);
		}
	}
}